package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.result.Result;
import com.itheima.health.pojo.vo.BusinessReportDataVO;
import com.itheima.health.pojo.vo.MemberReportVO;
import com.itheima.health.pojo.vo.SetmealReportVO;
import com.itheima.health.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/report")
@Slf4j
public class ReportController {

    @Autowired
    private ReportService reportService;

    /**
     * 统计会员数量
     *
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport() {
        log.info("[统计分析-统计会员数量]~");
        MemberReportVO memberReportVO = reportService.getMemberReport();
        return new Result(true, MessageConst.GET_MEMBER_NUMBER_REPORT_SUCCESS, memberReportVO);
    }

    /**
     * 统计套餐数量
     *
     * @return
     */
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport() {
        log.info("[统计分析-统计套餐数量]~");
        SetmealReportVO setmealReportVO = reportService.getSetmealReportVO();
        return new Result(true, MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS, setmealReportVO);
    }

    /**
     * @Author liyichen
     * @Description 获取营业数据
     * @Date 17:32 2024/7/10
     * @param
     * @return com.itheima.health.pojo.result.Result
     */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData() {
        BusinessReportDataVO businessReportDataVO=reportService.getBRDV();
        return new Result(true,MessageConst.GET_BUSINESS_REPORT_SUCCESS,businessReportDataVO);
    }

    /**
     * @Author liyichen
     * @Description 导出成excel
     * @Date 9:39 2024/7/11
     * @param
     * @return
     */
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response) {
        reportService.exportBusinessReport(response);
    }

}
